package com.totoro.rabbitmq.producer;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2017/9/14.
 */
@RestController
public class SendMsgController {
    @Resource
    SendService sendService ;

    @GetMapping("/send/fanout/{exchange}/{msg}")
    public String sendFanout(@PathVariable String exchange, @PathVariable String msg){
        sendService.sendMsgByFanout(exchange,msg);
        return "fanout" ;
    }

    @GetMapping("/send/fanout/student/{exchange}/{msg}")
    public String sendFanout_student(@PathVariable String exchange, @PathVariable String msg){
        sendService.sendMsgByFanout_student(exchange,msg);
        return "fanout" ;
    }
    @GetMapping("/send/direct/{exchange}/{routingKey}/{msg}")
    public String sendDirect(@PathVariable String exchange, @PathVariable String routingKey, @PathVariable String msg){
        sendService.sendMsgByDirectOrTopic(exchange,routingKey,msg);
        return "direct" ;
    }

    @GetMapping("/send/topic/{exchange}/{routingKey}/{msg}")
    public String sendTopic(@PathVariable String exchange, @PathVariable String routingKey, @PathVariable String msg){
        sendService.sendMsgByDirectOrTopic(exchange,routingKey,msg);
        return "topic" ;
    }

    @GetMapping("/send/headers/{exchange}/{msg}")
    public String sendTopic(@PathVariable String exchange,  @PathVariable String msg){
        sendService.sendMsgByHeaders(exchange, null, msg);
        return "headers" ;
    }

}
